Total Complexity | 2 |
Total Lines | 15 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { QueryHandler } from '@nestjs/cqrs'; |
||
7 | |||
8 | @QueryHandler(GetCooperativeQuery) |
||
9 | export class GetCooperativeQueryHandler { |
||
10 | constructor( |
||
11 | @Inject('ICooperativeRepository') |
||
12 | private readonly cooperativeRepository: ICooperativeRepository |
||
13 | ) {} |
||
14 | |||
15 | public async execute(query: GetCooperativeQuery): Promise<CooperativeView> { |
||
16 | const cooperative = await this.cooperativeRepository.find(); |
||
17 | if (!cooperative) { |
||
18 | throw new CooperativeNotFoundException(); |
||
19 | } |
||
20 | |||
21 | return new CooperativeView(cooperative.getDayDuration()); |
||
22 | } |
||
24 |